<template>
  <view class="weather-widget">
    <button @click="goToWeatherPage">获取天气预报</button>
  </view>
</template>

<script setup>
const goToWeatherPage = () => {
  console.log('点击了获取天气预报按钮，准备跳转...');
  // 跳转TabBar页面必须使用switchTab
  uni.switchTab({
    url: '/pages/weather/weather',
    success: () => {
      console.log('跳转天气Tab页成功');
    },
    fail: (err) => {
      console.error('跳转天气Tab页失败：', err);
      uni.showToast({ title: '跳转失败', icon: 'none' });
    }
  });
};
</script>

<style scoped>
.weather-widget {
  padding: 20rpx;
  background: #fff;
  border-radius: 12rpx;
  margin-bottom: 20rpx;
}
button {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background: #007aff;
  color: #fff;
  border-radius: 10rpx;
}
</style>